package no.ntnu.idi.lemma;
import java.io.IOException;
import org.annolab.tt4j.TreeTaggerException;
import no.ntnu.idi.deid.documentunits.*;
import no.ntnu.idi.deid.postprocessor.DocumentReConstructer;
import no.ntnu.idi.deid.preprocessor.Documents;





public class LemmatiseringMain {
	
	private static void searchStemmedWord(Token token) {
		NorkompleksGroup group = Norkompleks.getInstance().search(token);
		if(group != null) {
			if(!token.getStripped().equalsIgnoreCase(group.getStemWord())) {
				token.setStemmedToken(group.getStemWord());
			}
		}
	}
	
	public static void main(String[] args) {
		try {
			Documents d = new Documents();
			for(Document document: d) {
				for(Section section: document) {
					for(Sentence sentence: section) {
						for(Token token: sentence) {
							searchStemmedWord(token);
						}
					}
				}
			}
			DocumentReConstructer.constructLemmatizedFiles(d);		
		} catch (IOException | TreeTaggerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}
